package com.example.trb.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.example.trb.entity.group.Insert;
import com.example.trb.entity.group.Update;
import com.example.trb.validation.DateTime;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;
import java.util.List;

@Data
@TableName(autoResultMap = true)
public class PerformancePatent {
    @TableId(type = IdType.AUTO)
    private Integer id;

    @NotNull(groups = {Insert.class})
    @Null(groups = {Update.class})
    private Integer reviewFormId;

    @NotBlank(message = "专利名称不能为空", groups = {Update.class, Insert.class})
    private String name;

    @NotBlank(message = "专利类型不能为空", groups = {Update.class, Insert.class})
    @Length(max = 4, groups = {Update.class, Insert.class})
    private String type;

    @DateTime(message = "专利获取时间不合法", groups = {Update.class, Insert.class})
    private String acquireTime;

    @NotBlank(message = "专利介绍不能为空", groups = {Update.class, Insert.class})
    private String introduction;

    @Size(min = 1, message = "专利证明材料至少要有一个", groups = {Update.class, Insert.class})
    @Size(max = 3, message = "专利证明材料最多只能有三个", groups = {Update.class, Insert.class})
    @TableField(typeHandler = FastjsonTypeHandler.class)
    private List<String> materials;

    @Pattern(regexp = "待审核|未通过|已通过")
    private String status;
}
